//
//  PlayVoice.m
//  MyProject
//
//  Created by jiaming yan on 2018/3/15.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "PlayVoice.h"

@implementation PlayVoice

+(void )audioPlayWithUrl:(NSString *)urlStr{
    NSURL *url=[NSURL URLWithString:urlStr];
    
    
    AVPlayerItem * songItem = [[AVPlayerItem alloc]initWithURL:url];
    AVPlayer * player = [[AVPlayer alloc]initWithPlayerItem:songItem];
    [player play];
    
//    NSError *error=nil;
//    //初始化播放器，注意这里的Url参数只能时文件路径，不支持HTTP Url
//    AVAudioPlayer *audioPlayer=[[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
//    //设置播放器属性
//    audioPlayer.numberOfLoops=0;//设置为0不循环
////    _audioPlayer.delegate=self;
//    [audioPlayer prepareToPlay];//加载音频文件到缓存
//    if(error){
//        NSLog(@"初始化播放器过程发生错误,错误信息:%@",error.localizedDescription);
//    }else{
//        [audioPlayer play];
//    }
    
}
@end
